1
/************************************* Module Header **************************************\
2 * Module Name: MainWindow.xaml.cs
3 * Project: CSWPFDataBinding
4 * Copyright (c) Microsoft Corporation.
6 * The sample demonstrates how to display a series of photos just like a digital
7 * picuture frame with a "Wipe" effect.
10 * This source is subject to the Microsoft Public License.
11 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
12 * All other rights reserved.
15 * * 11/23/2009 3:00 PM Linda Liu Created
17 \******************************************************************************************/
20 using System
.Collections
.Generic
;
24 using System
.Windows
.Controls
;
25 using System
.Windows
.Data
;
26 using System
.Windows
.Documents
;
27 using System
.Windows
.Input
;
28 using System
.Windows
.Media
;
29 using System
.Windows
.Media
.Imaging
;
30 using System
.Windows
.Navigation
;
31 using System
.Windows
.Shapes
;
32 using System
.Windows
.Media
.Animation
;
34 namespace CSWPFAnimatedImage
37 /// Interaction logic for Window1.xaml
39 public partial class MainWindow
: Window
43 InitializeComponent();
47 List
<BitmapImage
> images
= new List
<BitmapImage
>();
49 private void Window_Loaded(object sender
, RoutedEventArgs e
)
51 // initialize the images collection
52 images
.Add(new BitmapImage(new Uri("Images/image1.jpg", UriKind
.Relative
)));
53 images
.Add(new BitmapImage(new Uri("Images/image2.jpg", UriKind
.Relative
)));
54 images
.Add(new BitmapImage(new Uri("Images/image3.jpg", UriKind
.Relative
)));
55 images
.Add(new BitmapImage(new Uri("Images/image4.jpg", UriKind
.Relative
)));
60 private void VisbleToInvisible_Completed(object sender
, EventArgs e
)
62 // change the source of the myImage1 to the next image to be shown
63 // and increase the nextImageIndex
64 this.myImage1
.Source
= images
[nextImageIndex
++];
66 // if the nextImageIndex exceeds the top bound of the ocllection,
67 // get it to 0 so as to show the first image next time
68 if (nextImageIndex
== images
.Count
)
73 // get the InvisibleToVisible storyboard and start it
74 Storyboard sb
= this.FindResource("InvisibleToVisible") as Storyboard
;
79 private void InvisibleToVisible_Completed(object sender
, EventArgs e
)
81 // change the source of the myImage2 to the next image to be shown
82 // and increase the nextImageIndex
83 this.myImage2
.Source
= images
[nextImageIndex
++];
85 // if the nextImageIndex exceeds the top bound of the ocllection,
86 // get it to 0 so as to show the first image next time
87 if (nextImageIndex
== images
.Count
)
92 // get the VisibleToInvisible storyboard and start it
93 Storyboard sb
= this.FindResource("VisibleToInvisible") as Storyboard
;